package com.turing.usdtpay.mvp.presenter;

import android.app.Activity;

import com.turing.usdtpay.http.ApiService;
import com.turing.usdtpay.http.ApiUrl;
import com.turing.usdtpay.http.callback.ApiCallback;
import com.turing.usdtpay.http.entity.ResponseDate;
import com.turing.usdtpay.mvp.contract.ChangePwdContract;

import java.util.HashMap;

/**
 * @作者：JAY
 * @创建时间：2019/11/1 17:25
 * @描述：
 **/
public class ChangePwdPresent implements ChangePwdContract.Present {
    private ChangePwdContract.View mView;

    public ChangePwdPresent(ChangePwdContract.View mView) {
        this.mView = mView;
    }

    @Override
    public void changePwd(Activity activity,String account, String pwd, String new_pwd) {
        HashMap<String, String> map= new HashMap<>();
        map.put("old_pwd",pwd);
        map.put("new_pwd",new_pwd);
        ApiService.getInstance().postRequestWithCommmon(activity, ApiUrl.API_CHANGE_PWD,map , new ApiCallback() {
            @Override
            public void onSuccess(int code, ResponseDate date) {
                if (date.getRet() == 1){
                    mView.changeSuccess();
                }else {
                    mView.onFail(date.getMsg());
                }
            }

            @Override
            public void onFailure(Throwable exception) {
                mView.onFail(exception.getMessage());
            }
        });

    }
}
